package com.jifeng.sterilizer.controller;

import java.util.Arrays;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.jifeng.sterilizer.entity.ControllerTypeEntity;
import com.jifeng.sterilizer.service.ControllerTypeService;
import com.jifeng.sterilizer.utils.PageUtils;
import com.jifeng.sterilizer.utils.R;



/**
 * 中控机类型表
 *
 * @author jifeng
 * @email 1593140625@qq.com
 * @date 2020-07-26 15:15:14
 */
@RestController
@RequestMapping("sterilizer/controllertype")
public class ControllerTypeController {
    @Autowired
    private ControllerTypeService controllerTypeService;

    /**
     * 根据名称模糊查询 PC
     */
    @GetMapping("/pc/type/name/list")
    public R getInfo(@RequestParam Map<String, Object> params){
        R rs = controllerTypeService.getByName(params);

        return rs;
    }

    /**
     * 查询中控器类型列表
     */
    @GetMapping("/pc/type/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = controllerTypeService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @GetMapping("/info/{id}")
    public R info(@PathVariable("id") Long id){
		ControllerTypeEntity controllerType = controllerTypeService.getById(id);

        return R.ok().put("controllerType", controllerType);
    }

    /**
     * 新增中控器类型
     */
    @PostMapping("/pc/type/add")
    public R add(@RequestBody ControllerTypeEntity controllerType){
		R rs= controllerTypeService.add(controllerType);

        return rs;
    }

    /**
     * 修改中控器类型
     */
    @PostMapping("/pc/type/update")
    public R update(@RequestBody ControllerTypeEntity controllerType){
	R rs=	controllerTypeService.myUpdate(controllerType);

        return rs;
    }

    /**
     * 删除中控器类型
     */
    @PostMapping("/pc/type/del")
    public R delete(@RequestBody Map<String, Object> params){
		R rs= controllerTypeService.del(params);

        return rs;
    }

}
